Skip to content

Conversation

@mbiagetti
Copy link
Contributor

@mbiagetti mbiagetti commented Jan 29, 2026

Adds a create_extension boolean field to extension metadata so that extensions providing only libraries or tools (e.g. wal2json) can skip CREATE EXTENSION tests. When create_extension is false, the extension is omitted entirely from the Database CR's extensions_spec and the status assertion skips the extensions field.

The generated database_assert_status map conditionally includes or excludes the extensions key, avoiding the Chainsaw limitation where extensions: null would require the field to exist in the actual resource. The psql verification job in check-extension.yaml also reads create_extension and skips when false.

Example generated values for create_extension: true (pgvector):

name: pgvector
sql_name: vector
shared_preload_libraries: []
pg_image: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
version: 0.8.1
create_extension: true
extensions:
    - name: pgvector
      image:
        reference: registry.pg-extensions:5000/pgvector-testing:0.8.1-18-trixie
database_config:
    extensions_spec:
        - ensure: present
          name: vector
          version: 0.8.1
database_assert_status:
    applied: true
    observedGeneration: 1
    extensions:
        - applied: true
          name: vector

Example generated values for create_extension: false (wal2json):

name: wal2json
sql_name: wal2json
shared_preload_libraries: []
pg_image: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
version: 2.6
create_extension: false
extensions:
    - name: wal2json
      image:
        reference: registry.pg-extensions:5000/wal2json-testing:2.6-18-trixie
database_config: {}
database_assert_status:
    applied: true
    observedGeneration: 1

Closes #85

@mbiagetti mbiagetti requested review from a team and NiccoloFei as code owners January 29, 2026 16:28
@NiccoloFei NiccoloFei force-pushed the mbiagetti/dev/85 branch 4 times, most recently from 60a3587 to 26b1448 Compare February 5, 2026 13:29
Signed-off-by: Gabriele Bartolini <[email protected]>
@gbartolini
Copy link
Contributor

I have tried this patch using an extension that doesn't need create extension like wal2json but I see that the tests are run anyway on the database.yaml file which still lists the extension:

apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
  name: (join('-', [$values.name, 'app']))
spec:
  name: app
  owner: app
  cluster:
    name: ($values.name)
  extensions: ($values.database_config.extensions_spec)

In my opinion, this test should be skipped or, if we want to, we should use a template that adds the extensions option only if the create extension capability is provided by the extension.

TestingValues was missing the CreateExtension field, so the generated
values.yaml never contained create_extension, causing the psql
verification job to always skip.

Closes cloudnative-pg#85

Signed-off-by: Marco Nenciarini <[email protected]>
…gistry calls

Bundle extension metadata with its configuration so
generateDatabaseConfig no longer re-parses metadata or re-fetches
image annotations for each extension.

Signed-off-by: Marco Nenciarini <[email protected]>
is false

Instead of listing extensions with ensure: absent in the Database CR,
skip them entirely from the extensions spec and expected status. This
avoids creating unnecessary extension entries in the Database CR for
library-only images like wal2json that don't provide a formal Postgres
extension object.

When all extensions have create_extension = false, both extensions_spec
and expected_status are omitted from the generated values, causing the
Database CR to have no extensions field and the assertion to expect no
extension status.

Signed-off-by: Marco Nenciarini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make CREATE EXTENSION tests optional

5 participants